package com.jayqqaa12.jbase.util.apk;

import com.sinaapp.msdxblog.apkUtil.entity.ApkInfo;
import com.sinaapp.msdxblog.apkUtil.utils.ApkUtil;

public class ApkUtils {

	public static String AAPT_PATH = "/root/android-sdk-linux/build-tools/19.0.1/aapt";

	public static void setAaptPath(String path) {
		AAPT_PATH = path;
	}

	public static ApkInfo getApkInfo(String apkPath) throws Exception {
		ApkInfo apkInfo = null;
		ApkUtil apk = new ApkUtil();
		if (AAPT_PATH != null) apk.setmAaptPath(AAPT_PATH);
		apkInfo = apk.getApkInfo(apkPath);

		return apkInfo;
	}

	/***
	 * 
	 * @param apkPath
	 * @param iconPath
	 *            导出的图标 地址
	 * @return
	 * @throws Exception
	 */
	public static ApkInfo getApkInfo(String apkPath, String iconPath) throws Exception {
		ApkInfo apkInfo = getApkInfo(apkPath);
		if (apkInfo != null) {
			IconUtil.extractFileFromApk(apkPath, apkInfo.getApplicationIcon(), iconPath);
		}
		return apkInfo;
	}

}
